1. Field of the Invention
The invention relates a method, an apparatus, a storage medium, a program, and a program product, for displaying a plurality of transparent primitive surfaces (transparent primitive surfaces or translucent primitive surfaces) provided in a virtual three-dimensional space.
2. Description of Related Art
Conventionally, a game apparatus for displaying a virtual three-dimensional space created by three-dimensional computer graphics is known. Such a game apparatus arranges objects consisting of a plurality of polygons (primitive surfaces) in a virtual three-dimensional space represented in a world coordinate system, and generates images viewed from a view point in the virtual three-dimensional space.
That is, the game apparatus operates coordinate values and a direction of each object (polygons constituting each object, vertexes constituting each polygon) in the world coordinate system. Then, the game apparatus determines a view point, an eyes direction, and a view volume (a field of view; a pyramid determined by a field of view angle and a Z direction depth of field) of the view point, and transforms the coordinate values and the direction of each object represented in the world coordinate system to those represented in a viewing coordinate system. Then, the game apparatus performs a hidden surfaces processing to the polygons, and perspective projects the polygons in a screen coordinate system. Thereby, the game apparatus decides a color of each pixel of a frame buffer (a screen).
As one algorithm of the hidden surfaces processing, it is a Z buffer algorithm. In order to perform the Z buffer algorithm, the game apparatus prepares a Z buffer that is a storage area therein. The Z buffer is a storage area storing Z values in the screen coordinate system, corresponding to pixels stored in the frame buffer, respectively. According to the Z buffer algorithm, the game apparatus perspective projects all polygons on the screen in voluntary order. Herein, when perspective projecting any one of polygons on the screen, the game apparatus performs the following processing.
That is, in case Z values of pixels occupied by the perspective projected polygon are not stored in the Z buffer, the game apparatus stores the color of the point of the polygon corresponding to each pixel in the frame buffer, in the pixel of the frame buffer. On the other hand, in case Z values of pixels occupied by the polygon are stored in the Z buffer, the game apparatus compares the Z value of the point of the polygon corresponding to each pixel with the Z value of the pixel. Then, in case the Z value of the point of the polygon is smaller than the Z value of the pixel corresponding to the point, the game apparatus rewrites the Z value of the pixel to the Z value of the point, stores the Z value of the point in the Z buffer, and provides the color of the point to the pixel. On the other hand, in the case the Z value of the point of the polygon is larger than the Z value of the pixel corresponding to the point, the game apparatus does not rewrite the Z value of the pixel, and does not provide the color of the point to the pixel. When the game apparatus outputs values stored in the frame buffer after performing the above-described processing to each pixel, it is possible that the game apparatus performs the hidden surfaces processing to all polygons.
As another algorithm of the hidden surfaces processing, it is a back surfaces clipping algorithm. The back surfaces clipping algorithm is an algorithm of performing the hidden surfaces processing without perspective projecting all polygons. According to the back surfaces clipping algorithm, the game apparatus performs the following processing to each object provided in the virtual three-dimensional space.
That is, the game apparatus determines whether each polygon constituting the object is at the view point side (the front) of the object or the opposite side (the back) to the view point, on the basis of an eyes direction and direction of a normal of each polygon. More specifically, the game apparatus operates an angle between a normal vector of each polygon and an eyes vector, decides that the polygon is at the back in case the angle is an acute angle, and decides that the polygon is at the front in case the angle is an obtuse angle. Then, the game apparatus transforms only the polygons at the front to those represented in the screen coordinate system, and thereby determines the color of each pixel stored in the frame buffer. Therefore, because the game apparatus displays only the front of each object, it is possible that the game apparatus performs the hidden surfaces processing to all polygons.
By the way, in order to display more realistic images on a display screen, there is a case a transparent object or a translucent object such as a window glass or a water surface is provided in the virtual three-dimensional space. Hereinafter, the transparent object and the translucent object will be called a transparent object. The game apparatus displays the transparent object on the screen by performing the following processing.
That is, the game apparatus perspective projects the transparent object on the screen coordinate system, and determines colors of pixels corresponding to points included in each transparent polygon of the transparent object, according to an alpha value of the transparent object. More specifically, the game apparatus composes the color of each pixel decided before displaying the transparent polygon on the screen and the color of the transparent polygon, according to the alpha value, and thereby determines each pixel of the frame buffer. When the game apparatus performs the above-described processing to all transparent polygons constituting the transparent object, the transparent object is displayed on the screen.
In the game apparatus according to an earlier development, there are the following problems in case the game apparatus performs the hidden surfaces processing to the transparent polygon.
When the game apparatus carries out the hidden surfaces processing according to the Z buffer algorithm, because the game apparatus perspective projects all polygons in voluntary order, there is a case the display on the screen is influenced by the projection order. For example, in case another polygon is provided at the far side of the transparent polygon in the eyes direction, there is a difference in the display on the screen between the case the game apparatus perspective projects the transparent polygon first and the case the game apparatus perspective projects another polygon first.
That is, in case the game apparatus perspective projects the transparent polygon after perspective projecting another polygon first, because the Z value of the point included in the transparent polygon is smaller than the Z value of the pixel stored in the frame buffer, that is the Z value of the point included in another polygon, the game apparatus composes the color of the transparent polygon and the color of the frame buffer, that is the color of another polygon. Therefore, the images are displayed on the display screen so that another polygon is always at the far side of the transparent polygon. On the other hand, in case the game apparatus perspective projects another polygon after perspective projecting the transparent polygon first, because the Z value of the point included in another polygon is larger than the Z value of the pixel stored in the frame buffer, that is the Z value of the point included in the transparent polygon, the game apparatus does not provide the color of another polygon to the pixel. Therefore, in spite of the transparent polygon, the color of another polygon is not reflected in the transparent polygon on the display screen.
Further, according to the Z buffer algorithm, even if another object is not provided at the far side of the transparent object in the eyes direction, there is a difference in displaying the transparent object on the screen between the case the game apparatus perspective projects the front polygon constituting the transparent polygon after perspective projecting the back polygon and the case the game apparatus perspective projects the back polygon constituting the transparent polygon after perspective projecting the front polygon.
That is, in case the game apparatus perspective projects the front polygon of the transparent polygon after perspective projecting the back polygon first, because the Z value of the front polygon is smaller than the Z value of the pixel stored in the frame buffer, that is the Z value of the back polygon, the game apparatus composes the color of the front polygon and the color of the frame buffer. On the other hand, in case the game apparatus perspective projects the back polygon of the transparent polygon after perspective projecting the front polygon first, because the Z value of the back polygon is larger than the Z value of the pixel stored in the frame buffer, that is the Z value of the front polygon, the game apparatus does not provide the color of the back polygon to the pixel.
Therefore, concerning the transparent object, the game apparatus avoids that the projecting order of polygons has an influence on the display of the transparent object, by performing the hidden surfaces processing according to the back surfaces clipping algorithm.
However, according to the back surfaces clipping algorithm, because the color of the back polygon of the transparent polygon is not reflected on the display screen, there is a case the reality lacks. For example, in case the color of the back polygon of the transparent object is different from the color of the front polygon, the color of the back polygon is not reflected on the pixel. Accordingly, in spite of the transparent object, only the color of the front polygon of the transparent object is displayed on the display screen. Further, for example, in spite of the fact that the light is irradiated and reflected to the back of the transparent object, it is impossible that images are displayed on the display screen so that the light is reflected on the back of the transparent object.
The present invention was developed in view of the above-described problems.
It is an object of the present invention to reflect color data of back surfaces (far sides) of a plurality of transparent polygons overlapped with each other in an eyes direction, on a display screen.
In accordance with a first aspect of the present invention, a method for generating image data of a virtual three-dimensional space viewed from a predetermined view point, comprises:
determining (for example, a space operation unit 110 shown in FIG. 4) a plurality of transparent primitive surfaces in the virtual three-dimensional space;
operating (for example, a space operation unit 110 shown in FIG. 4) an angle between an eyes direction at the predetermined view point and a normal direction to each of the transparent primitive surfaces;
deciding (for example, a projection order decision unit 154 shown in FIG. 4) a description order of the plurality of transparent primitive surfaces so as to give priority one of the transparent primitive surfaces when the angle is an acute angle over one of the transparent primitive surfaces when the angle is an obtuse angle; and
describing (for example, a perspective projection unit 156 shown in FIG. 4) the plurality of transparent primitive surfaces by composing color data of the transparent primitive surfaces in the description order.
According to the method of the first aspect of the present invention, it is possible to determine whether a front of each of the transparent primitive surfaces is turned to the view point or not, by operating the angle between the eyes direction and the normal direction of each of the transparent primitive surfaces.
For example, in case a plurality of transparent primitive surface constitute one object (model), the transparent primitive surface the front of which is not turned to the view point (Hereinafter, it will be called a back transparent primitive surface.) is a primitive surface constituting a back of the object, and the transparent primitive surface the front of which is turned to the view point (Hereinafter, it will be called a front transparent primitive surface.) is a primitive surface constituting a front of the object. In other words, basically, the front transparent primitive surface is positioned at the nearer side of the view point than the back transparent primitive surface.
Therefore, because when color data of the back transparent primitive surfaces are composed prior to the front transparent primitive surfaces, the back transparent primitive surfaces are described, the color data of the back transparent primitive surfaces are reflected on color data of the front transparent primitive surfaces, and the front transparent primitive surfaces are described. Accordingly, it is possible to express an image as the back transparent primitive surface is at the far side of the front transparent primitive surface. Consequently, for example, because it is possible to express an image as the reflection of light on the back transparent primitive surface is reflected on the front transparent primitive surface, it is possible to display the realistic image on a screen.
Herein, the primitive surface is a surface constituting a model (object). In case the model is a surface model, the primitive surface is at least one polygon constituting the model. Further, in case the model is a solid model, the primitive surface is a plane constituting a face of the model.
Preferably, the method according to the first aspect of the present invention, further comprises: deciding the description order of the plurality of transparent primitive surfaces so as to give priority one of the transparent primitive surfaces when the angle is an acute angle over another of the transparent primitive surfaces when the angle is an acute angle in order of far from the predetermined view point and so as to give priority one of the transparent primitive surfaces when the angle is an obtuse angle over another of the transparent primitive surfaces when the angle is an obtuse angle in order of far from the predetermined view point.
According to the above-described method, although there is a case a plurality of front transparent primitive surfaces are overlapped with each other in the eyes direction at some view point, because the plurality of front transparent primitive surfaces are described in order of far from the view point, one front transparent primitive surface is described with color data on which color data of another front transparent primitive surface at the far side of the one front transparent primitive surface are reflected. Consequently, it is possible to express an image as one front transparent primitive surface is at the far side of another front primitive surface.
In case a plurality of back transparent primitive surfaces are overlapped with each other in the eyes direction like the case of the front transparent primitive surfaces, it is possible to express an image as one back transparent primitive surface is at the far side of another back primitive surface.
In accordance with a second aspect of the present invention, a method for generating image data of a virtual three-dimensional space viewed from a predetermined view point, comprises:
determining (for example, a space operation unit 110 shown in FIG. 4) a plurality of transparent primitive surfaces in the virtual three-dimensional space;
deciding (for example, a projection order decision unit 154 shown in FIG. 4) a description order of the plurality of transparent primitive surfaces in order of far from the predetermined view point; and
describing (for example, a perspective projection unit 156 shown in FIG. 4) the plurality of transparent primitive surfaces by composing color data of the transparent primitive surfaces in the description order.
According to the method of the second aspect of the present invention, because the description order of a plurality of transparent primitive surfaces is decided in order of far from the view point, color data of the plurality of transparent primitive surfaces are composed in the decided description order, and the transparent primitive surfaces are described, the transparent primitive surface at the near side in the eyes direction is described with color data on which color data of the transparent primitive surface at the far side in the eyes direction from the view point are reflected. Consequently, it is possible to express an image as one transparent primitive surface is at the far side of another transparent primitive surface. Further, because the description order of all transparent primitive surfaces is decided, even if a number of transparent primitive surfaces are overlapped in the eyes direction from the view point, the transparent primitive surface at the nearest side can be described with color data on which color data of the transparent primitive surface at the farthest side are reflected.
Preferably, the method according to the first aspect or the second aspect of the present invention, further comprises: describing a primitive surface other than the plurality of transparent primitive surfaces before describing the transparent primitive surfaces.
According to the above-described method, for example, in case a transparent primitive surface and a primitive surface (Hereinafter, it will be called a different primitive surface.) other than the transparent primitive surface are positioned in order and overlapped with each other, in the eyes direction from the view point, it will take the following effect. That is, because the different primitive surface is described first, the transparent primitive surface at the near side can be described with color data on which color data of the different primitive surface is reflected.
Preferably, the method as described above, further comprises: performing a predetermined hidden surfaces processing to the primitive surface other than the plurality of transparent primitive surfaces and the plurality of transparent primitive surfaces, and describing the transparent primitive surfaces.
According to the above-described method, for example, in case the different primitive surface and the transparent primitive surface are positioned in order and overlapped with each other, in the eyes direction from the view point, because the hidden surfaces processing is performed to the different primitive surface, even if the transparent primitive surface is to be described, it is impossible to described the transparent primitive surface.
Preferably, the method according to the first aspect or the second aspect of the present invention, further comprises:
deciding the description order so as to give priority an object including primitive surfaces other than the plurality of transparent primitive surfaces over an object including the plurality of transparent primitive surfaces, for every object; and
describing the primitive surfaces other than the plurality of transparent primitive surfaces and the transparent primitive surfaces, for every object, in the description order.
According to the above-described method, because the description order of the transparent primitive surfaces and the different primitive surfaces is decided for every object, the processing of deciding the description order can be carried out faster than the processing of deciding the description order for every primitive surface the number of which is more than one of objects.
In accordance with a third aspect of the present invention, a method for generating image data of a virtual three-dimensional space viewed from a predetermined view point, comprises:
determining (for example, a space operation unit 110 shown in FIG. 4) a plurality of primitive surfaces including an opaque primitive surface and a plurality of transparent primitive surfaces in the virtual three-dimensional space;
deciding (for example, a projection order decision unit 154 shown in FIG. 4) a first description order of the plurality of primitive surfaces so as to give priority the opaque primitive surface over the plurality of transparent primitive surfaces;
operating (for example, a space operation unit 110 shown in FIG. 4) an angle between an eyes direction at the predetermined view point and a normal direction to each of the transparent primitive surfaces;
deciding (for example, a projection order decision unit 154 shown in FIG. 4) a second description order of the plurality of transparent primitive surfaces so as to give priority one of the transparent primitive surfaces when the angle is an acute angle over one of the transparent primitive surfaces when the angle is an obtuse angle; and
performing (for example, a perspective projection unit 156 shown in FIG. 4) a hidden surfaces processing to the plurality of primitive surfaces according to a Z buffer algorithm, writing color data of the opaque primitive surface in a frame buffer (for example, a frame buffer 170 shown in FIG. 4), and writing color data composed of color data of each of the transparent primitive surfaces and the color data written in the frame buffer, in the frame buffer, in the first description order and the second description order.
According to the method of the third aspect of the present invention, it is possible to determine whether a front of each of the transparent primitive surfaces is turned to the view point or not, by operating the angle between the eyes direction and the normal direction of each of the transparent primitive surfaces.
For example, in case a plurality of transparent primitive surface constitute one object, a front transparent primitive surface constitutes one of a back of the object, and a back transparent primitive surface constitutes one of a front of the object. In other words, basically, the front transparent primitive surface is positioned at the nearer side of the view point than the back transparent primitive surface.
Further, on the basis of the first description order and the second description order, the order of the primitive surfaces is decided to be an order of the opaque primitive surface, the back transparent primitive surface and the front transparent primitive surface.
For example, in case of any one of (1) the opaque primitive surface, the front transparent primitive surface and the back transparent primitive surface are positioned and overlapped in order, (2) the front transparent primitive surface, the opaque primitive surface and the back transparent primitive surfaces are positioned and overlapped in order, and (3) the front transparent primitive surface , the back transparent primitive surface and the opaque primitive surface are positioned and overlapped in order, in the eyes direction from the view point, it is possible to display the realistic image on the screen.
That is, in case of (1), although color data of the opaque primitive surface is written in the frame buffer first, because the front transparent primitive surface and the back transparent primitive surface are hidden according to the Z buffer algorithm, color data of the front transparent primitive surface and the back transparent primitive surface are not composed to the color data written in the frame buffer. Accordingly, because the image is generated as the opaque primitive surface is at the nearest side of the view point, it is possible to display the realistic image on the screen.
Further, in case of (2), although color data of the opaque primitive surface is written in the frame buffer first, because the back transparent primitive surface is hidden according to the Z buffer algorithm, color data of the back transparent primitive surface are not composed to the color data written in the frame buffer. On the other hand, because the front transparent primitive surface is not hidden according to the Z buffer algorithm, color data of the front transparent primitive surface are composed to the color data written in the frame buffer, and the composed color data are written in the frame buffer. Accordingly, because the image is generated as the opaque primitive surface is at the far side of the front transparent primitive surface, it is possible to display the realistic image on the screen.
Further, in case of (3), although color data of the opaque primitive surface is written in the frame buffer first. Then, because the back transparent primitive surface is not hidden according to the Z buffer algorithm, color data of the back transparent primitive surface are composed to the color data written in the frame buffer, and the composed color data are written in the frame buffer. Then, because the front transparent primitive surface is not hidden according to the Z buffer algorithm, color data of the front transparent primitive surface are composed to the color data written in the frame buffer, and the composed color data are written in the frame buffer. Accordingly, because the image is generated as the back transparent primitive surface is at the far side of the front transparent primitive surface, and the opaque primitive surface is at the far side of the back transparent primitive surface, it is possible to display the realistic image on the screen.
In accordance with a fourth aspect of the present invention, a method for generating image data of a virtual three-dimensional space viewed from a predetermined view point, comprises:
determining (for example, a space operation unit 110 shown in FIG. 4) a plurality of primitive surfaces including an opaque primitive surface and a plurality of transparent primitive surfaces in the virtual three-dimensional space;
deciding (for example, a projection order decision unit 154 shown in FIG. 4) a first description order of the plurality of primitive surfaces so as to give priority the opaque primitive surface over the plurality of transparent primitive surfaces;
deciding (for example, a projection order decision unit 154 shown in FIG. 4) a second description order of the plurality of transparent primitive surfaces in order of far from the predetermined view point; and
performing (for example, a perspective projection unit 156 shown in FIG. 4) a hidden surfaces processing to the plurality of primitive surfaces according to a Z buffer algorithm, writing color data of the opaque primitive surface in a frame buffer (for example, a frame buffer 170 shown in FIG. 4), and writing color data composed of color data of each of the transparent primitive surfaces and the color data written in the frame buffer, in the frame buffer, in the first description order and the second description order.
According to the method of the fourth aspect of the present invention, regarding the transparent primitive surface and the opaque primitive surface, the opaque primitive surface has priority over the transparent primitive surface on the description order, and a plurality of transparent primitive surfaces have priority in order of far from the view point on the description order. Consequently, even if a plurality of transparent primitive surfaces and the opaque primitive surface are positioned in any order in the eyes direction, it is possible to display the realistic image on the screen.
That is, for example, in case of any one of (1) the opaque primitive surface, a first transparent primitive surface and a second transparent primitive surface are positioned and overlapped in order, (2) the first transparent primitive surface, the opaque primitive surface and the second transparent primitive surfaces are positioned and overlapped in order, and (3) the first transparent primitive surface , the second transparent primitive surface and the opaque primitive surface are positioned and overlapped in order, in the eyes direction from the view point, it is possible to display the realistic image on the screen, like the case described in the third aspect of the present invention.
Preferably, the method of the first aspect or the second aspect of the present invention, further comprises:
determining (for example, a light sources determination unit 140 shown in FIG. 4) a light source in the virtual three-dimensional space;
operating (for example, a brightness operation unit 158 shown in FIG. 4) brightness of the transparent primitive surfaces on the basis of the light source; and
deciding (for example, a RGBxcex1 value decision unit 160 shown in FIG. 4) color data of the transparent primitive surfaces on the basis of the brightness.
According to the above-described method, because the brightness of the transparent primitive surfaces are operated on the basis of the light source, and the color data of the transparent primitive surfaces are decided on the basis of the brightness, for example, it is possible to express an image as light is reflected on the transparent primitive surface by bringing the color data of the transparent primitive surface into white color. Consequently, it is possible to display the more realistic image on the screen.
Preferably, the method of the first aspect or the second aspect of the present invention, further comprises: determining at least one of the transparent primitive surfaces to be at least one portion of a predetermined vehicle object or a predetermined plane object in the virtual three-dimensional space.
According to the above-described method, because at leas one of the transparent primitive surfaces is determined to be at least one portion of the vehicle object or the plane object, it is possible to express a window glass of the vehicle object or the plane object as the transparent primitive surface. Further, as described above, it is possible to express an image as one transparent primitive surface is at the far side of another transparent primitive surface, that is one window glass is at the far side of another window glass. Consequently, it is possible to generate the more realistic images of the vehicle object and the plane model.
In accordance with a fifth aspect of the present invention, a method for generating image data of a virtual three-dimensional space viewed from a predetermined view point, comprises:
composing color data of one of a plurality of transparent surfaces determined in the virtual three-dimensional space and color data of another of the transparent surfaces, to describe the transparent surfaces.
According to the method of the fifth aspect of the present invention, for example, in case one transparent surface is overlapped with another transparent surface in the eyes direction from the view point in the virtual three-dimensional space, because color data of the one transparent surface is composed to color data of the another transparent surface, it is possible to express an image as the another transparent surface is at the far side of the one transparent surface. Consequently, for example, because it is possible to generate an image as light reflected on the another transparent surface is reflected on the one transparent surface, it is possible to display the realistic image on the screen.
Preferably, the method of the first aspect or the second aspect of the present invention, performed on a game apparatus (for example, a game apparatus shown in FIG. 1), further comprises:
executing a predetermined game; and
generating game image data of the predetermined game, comprising the image data of the virtual three-dimensional space.
In accordance with a sixth aspect of the present invention, an apparatus is adapted to carry out the method as described above.
In accordance with a seventh aspect of the present invention, a storage medium has a program recorded thereon, when the program is loaded onto an operating apparatus, the program making the operating apparatus execute the method as described above.
In accordance with a eighth aspect of the present invention, a program, when the program is loaded onto an operating apparatus, makes the operating apparatus execute the method as described above.
In accordance with a ninth aspect of the present invention, a program product comprises a storage medium having a program recorded thereon, when the program is loaded onto an operating apparatus, the program making the operating apparatus execute the method as described above.